--[[
* 能量变更后
*]]
---@class BuffEffect87 : BaseBuffEffect
BuffEffect87 = ClientFight.CreateClass("BuffEffect87", ClientFight.BaseBuffEffect)
local t = BuffEffect87
---@param fight Fight
---@param buff FighterBuff

function t:action(fight, buff, ...)
    local parameters = {...};
    local f_BuffEffectValue = buff.getBuffBean().getF_BuffEffectValue();
    local targetType = f_BuffEffectValue[1];
    local fighterType = f_BuffEffectValue[2];
    local target = null;
    local fighter;
    if (targetType == 1) then
        target = buff.source;
    elseif (targetType == 2) then
        target = buff.target;
    elseif (targetType == 3) then
        target = parameters[1];
    end
    if (fighterType == 1) then
        fighter = buff.target;
    else
        fighter = buff.source;
    end
    local triggerSkillId = 0;
    for i = 3, table.getn(f_BuffEffectValue), 2 do
        local skillId = f_BuffEffectValue[i];
        local skillId2 = f_BuffEffectValue[i + 1];
        if (containsSkillId(skillId, fighter)) then
            triggerSkillId = skillId2;
            break ;
        end
    end
    if (triggerSkillId == 0) then
        return IBuffEffect.FAIL;
    end
    local logSkillId = triggerSkillId;
    SkillRoleMgr.savePathFile("[" .. fight.frame .. "][EFFECT]Fighter " .. buff.target.fighterId .. " Buff"
            .. buff.modelId .. " 触发释放技能：" .. logSkillId);

    triggerSkill(fight, fighter, target, triggerSkillId);

    return ClientFight.BaseBuffEffect.action(self, fight, buff, parameters);
end

function t:containsSkillId(skillId, source)
    local skills = source.skill;
    for k, skill in pairs(skills) do
        if (skill.skillId == skillId) then
            return true;
        end
    end
    local passiveskills = source.passiveskills;
    for k, skill in pairs(passiveskills) do
        if (skill.skillId == skillId) then
            return true;
        end
    end
    return false;
end
t.New()